﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PeriodConflictFinder
{
    public class EvenPeriodScheduleAlgorithm :IScheduleAlgorithm
    {
        
        public EvenPeriodScheduleAlgorithm(string name, DateTime dtStart, DateTime dtEnd, int IntervalMinutes, int runTimeMinutes)
        {
            this.Interval = IntervalMinutes;
            this.RunTime = runTimeMinutes;
            DateTime current = dtStart;
            Ocurrences = new List<DateRange>();
            Name = name;
            while (current < dtEnd)
            {
                Ocurrences.Add(new DateRange(current, current.AddMinutes(runTimeMinutes)));
                current = current.AddMinutes(IntervalMinutes);

            }

            DateRange dr = new DateRange(dtStart, dtEnd);
            this.Range = dr;

        }
        #region IScheduleAlgorithm Members

        public string Name
        {
            get;
            set;

        }

        public List<DateRange> Ocurrences
        {
            get;
            set;
        }

        public int AvgRunTime
        {
            get;
            set;
        }
        public int Interval { get; set; }
        
        #endregion

        #region IScheduleAlgorithm Members


               public int RunTime
        {
            get;
            set;
        }
        public DateRange Range { get; set; }
        #endregion
        public override string ToString()
        {
            return string.Format("{0} - {1} - {2}",this.Name, this.Range, this.Ocurrences.Count());
        }
            
    }
}
